package com.tang.algorithm.ordinary;


/**
 * @author tlm
 * @version 1.0
 * @date 2020/6/30 22:01
 */
public class LeetCode1374 {
    public static void main(String[] args) {
        System.out.println(generateTheString2(2));
    }

    public static String generateTheString(int n) {
        if (n == 0) return null;
        StringBuilder stringBuilder = new StringBuilder();
        if ((n & 1) == 0) {  //偶数
            for (int i = 0; i < n - 1; i++) {
                stringBuilder.append('a');
            }
            stringBuilder.append('b');
        } else {
            for (int i = 0; i < n; i++) {
                stringBuilder.append('a');
            }
        }
        return stringBuilder.toString();
    }

    public static String generateTheString2(int n) {
        StringBuilder stringBuilder = new StringBuilder();
        if (n == 0) {
            return null;
        }
        if ((n & 2) != 0) {  //偶数
            for (int i = 0; i < n - 1; i++) {
                stringBuilder.append('a');
            }
            stringBuilder.append('b');
        } else {
            for (int i = 0; i < n; i++) {
                stringBuilder.append('a');
            }
        }
        return stringBuilder.toString();
    }
}
